package cn.shop.core.service.impl;

import cn.shop.core.bean.UserInfo;
import cn.shop.core.dao.UserDAO;
import cn.shop.core.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2016/8/25.
 */
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDAO userDAO;

    public void deleteUser(UserInfo user) {
        userDAO.delete(user);
    }

    public Long getCount(UserInfo user) {
        Long count = userDAO.getCount(user);
        return count;
    }

    public void addUser(UserInfo user) {
        int i = userDAO.add(user);
        System.out.println(i);

    }

    public List<UserInfo> getList(UserInfo user) {
        if (user != null) {
            if (user.getUserName() != null && !user.getUserName().equals("")) {
                user.setUserName("%" + user.getUserName() + "%");
            }
        }
        List<UserInfo> list = userDAO.getUserList(user);
        return list;
    }

    public UserInfo getUserInfo(UserInfo user) {
        UserInfo u = userDAO.getUser(user);
        return u;
    }

    public void update(UserInfo user) {
        userDAO.updateUser(user);
    }

    public UserInfo userLogin(UserInfo user) {
        return userDAO.userLogin(user);
    }
}
